package cn.yuemouren.security.app;

import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: Timi
 * @Description: 将token中放入业务信息
 * @Date: 2020/7/5 15:34
 * @Version: v1.0
 */
public class TokenJwtEnhancer implements TokenEnhancer {
    @Override
    public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
        Map<String,Object> params = new HashMap<>();
        params.put("company","timi");
        ((DefaultOAuth2AccessToken)accessToken).setAdditionalInformation(params);
        return accessToken;
    }
}
